package cn.ibizlab.odoo.core.odoo_account.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Iaccount_move_line;
import cn.ibizlab.odoo.core.odoo_account.domain.Account_move_line;
import cn.ibizlab.odoo.core.odoo_account.filter.Account_move_lineSearchContext;
import cn.ibizlab.odoo.core.odoo_account.service.IAccount_move_lineService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[日记账项目] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Account_move_lineServiceImpl implements IAccount_move_lineService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Iaccount_move_lineClientService account_move_lineClientService;

    @Override
    public boolean update(Account_move_line account_move_line) {
        boolean bOk = false ;
        Iaccount_move_line clientModel = this.convert2Model(account_move_line,null);
        account_move_lineClientService.update(clientModel) ;
        this.convert2Domain(clientModel,account_move_line) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public boolean create(Account_move_line account_move_line) {
        boolean bOk = false ;
        Iaccount_move_line clientModel = this.convert2Model(account_move_line,null);
        account_move_lineClientService.create(clientModel) ;
        this.convert2Domain(clientModel,account_move_line);
        bOk = true ;

        return bOk ;
    }

    @Override
    public void createBatch(List<Account_move_line> account_move_lines, int batchSize) {

                        //account_move_lineClientService.createBatch(account_move_lines,batchSize) ;

    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //account_move_lineClientService.removeBatch(account_move_lines) ;

    }

    @Override
    public Account_move_line get(Integer id) {
        Iaccount_move_line clientModel = account_move_lineClientService.createModel();
        clientModel.setId(id);
        account_move_lineClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Account_move_line get(Account_move_line account_move_line) {
        Account_move_line retaccount_move_line = this.get(account_move_line.getId()) ;
    	BeanCopier copier=BeanCopier.create(retaccount_move_line.getClass(), account_move_line.getClass(), false);
        copier.copy(retaccount_move_line, account_move_line, null);
        return account_move_line ;
    }

    @Override
    public void updateBatch(List<Account_move_line> account_move_lines, int batchSize) {

        //account_move_lineClientService.updateBatch(account_move_lines,batchSize) ;

    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Iaccount_move_line clientModel = account_move_lineClientService.createModel();
        clientModel.setId(id);
        account_move_lineClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Account_move_line> searchDefault(Account_move_lineSearchContext context) {
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据科目类型查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_user_type(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据科目查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_account(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据分析账户查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_analytic_account(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据银行对账单明细查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_statement_line(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据银行对账单查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_statement(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据完全核销查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_full_reconcile(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据发票查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_invoice(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据日记账查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_journal(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据凭证录入查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_move(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据付款查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_payment(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据税率查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_tax_line(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据费用查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_expense(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_product(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_company(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据币种查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_company_currency(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据币种查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_currency(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_partner(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_create(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_write(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品计量单位查询
     */
    @Override
    public Page<Account_move_line> selectByOdoo_product_uom(Integer id){
        Account_move_lineSearchContext context = new Account_move_lineSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_move_line> list = new ArrayList<Account_move_line>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_move_line> clientModelList = account_move_lineClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_move_line clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_move_line>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Iaccount_move_line convert2Model(Account_move_line domain , Iaccount_move_line model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = account_move_lineClientService.createModel() ;
        }

         if(domain.getAnalytic_tag_idsDirtyFlag())
            model.setAnalytic_tag_ids(domain.getAnalytic_tag_ids());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getBalanceDirtyFlag())
            model.setBalance(domain.getBalance());
         if(domain.getTax_idsDirtyFlag())
            model.setTax_ids(domain.getTax_ids());
         if(domain.getAmount_currencyDirtyFlag())
            model.setAmount_currency(domain.getAmount_currency());
         if(domain.getTax_line_grouping_keyDirtyFlag())
            model.setTax_line_grouping_key(domain.getTax_line_grouping_key());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getReconciledDirtyFlag())
            model.setReconciled(domain.getReconciled());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getBalance_cash_basisDirtyFlag())
            model.setBalance_cash_basis(domain.getBalance_cash_basis());
         if(domain.getCredit_cash_basisDirtyFlag())
            model.setCredit_cash_basis(domain.getCredit_cash_basis());
         if(domain.getQuantityDirtyFlag())
            model.setQuantity(domain.getQuantity());
         if(domain.getAmount_residualDirtyFlag())
            model.setAmount_residual(domain.getAmount_residual());
         if(domain.getRecompute_tax_lineDirtyFlag())
            model.setRecompute_tax_line(domain.getRecompute_tax_line());
         if(domain.getTax_exigibleDirtyFlag())
            model.setTax_exigible(domain.getTax_exigible());
         if(domain.getAmount_residual_currencyDirtyFlag())
            model.setAmount_residual_currency(domain.getAmount_residual_currency());
         if(domain.getTax_base_amountDirtyFlag())
            model.setTax_base_amount(domain.getTax_base_amount());
         if(domain.getParent_stateDirtyFlag())
            model.setParent_state(domain.getParent_state());
         if(domain.getBlockedDirtyFlag())
            model.setBlocked(domain.getBlocked());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getMatched_credit_idsDirtyFlag())
            model.setMatched_credit_ids(domain.getMatched_credit_ids());
         if(domain.getAnalytic_line_idsDirtyFlag())
            model.setAnalytic_line_ids(domain.getAnalytic_line_ids());
         if(domain.getDate_maturityDirtyFlag())
            model.setDate_maturity(domain.getDate_maturity());
         if(domain.getDebitDirtyFlag())
            model.setDebit(domain.getDebit());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getCounterpartDirtyFlag())
            model.setCounterpart(domain.getCounterpart());
         if(domain.getMatched_debit_idsDirtyFlag())
            model.setMatched_debit_ids(domain.getMatched_debit_ids());
         if(domain.getDebit_cash_basisDirtyFlag())
            model.setDebit_cash_basis(domain.getDebit_cash_basis());
         if(domain.getCreditDirtyFlag())
            model.setCredit(domain.getCredit());
         if(domain.getNarrationDirtyFlag())
            model.setNarration(domain.getNarration());
         if(domain.getProduct_id_textDirtyFlag())
            model.setProduct_id_text(domain.getProduct_id_text());
         if(domain.getUser_type_id_textDirtyFlag())
            model.setUser_type_id_text(domain.getUser_type_id_text());
         if(domain.getPayment_id_textDirtyFlag())
            model.setPayment_id_text(domain.getPayment_id_text());
         if(domain.getTax_line_id_textDirtyFlag())
            model.setTax_line_id_text(domain.getTax_line_id_text());
         if(domain.getFull_reconcile_id_textDirtyFlag())
            model.setFull_reconcile_id_text(domain.getFull_reconcile_id_text());
         if(domain.getExpense_id_textDirtyFlag())
            model.setExpense_id_text(domain.getExpense_id_text());
         if(domain.getMove_id_textDirtyFlag())
            model.setMove_id_text(domain.getMove_id_text());
         if(domain.getJournal_id_textDirtyFlag())
            model.setJournal_id_text(domain.getJournal_id_text());
         if(domain.getCompany_currency_id_textDirtyFlag())
            model.setCompany_currency_id_text(domain.getCompany_currency_id_text());
         if(domain.getInvoice_id_textDirtyFlag())
            model.setInvoice_id_text(domain.getInvoice_id_text());
         if(domain.getAnalytic_account_id_textDirtyFlag())
            model.setAnalytic_account_id_text(domain.getAnalytic_account_id_text());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getCurrency_id_textDirtyFlag())
            model.setCurrency_id_text(domain.getCurrency_id_text());
         if(domain.getRefDirtyFlag())
            model.setRef(domain.getRef());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getStatement_id_textDirtyFlag())
            model.setStatement_id_text(domain.getStatement_id_text());
         if(domain.getStatement_line_id_textDirtyFlag())
            model.setStatement_line_id_text(domain.getStatement_line_id_text());
         if(domain.getPartner_id_textDirtyFlag())
            model.setPartner_id_text(domain.getPartner_id_text());
         if(domain.getAccount_id_textDirtyFlag())
            model.setAccount_id_text(domain.getAccount_id_text());
         if(domain.getDateDirtyFlag())
            model.setDate(domain.getDate());
         if(domain.getProduct_uom_id_textDirtyFlag())
            model.setProduct_uom_id_text(domain.getProduct_uom_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getMove_idDirtyFlag())
            model.setMove_id(domain.getMove_id());
         if(domain.getCurrency_idDirtyFlag())
            model.setCurrency_id(domain.getCurrency_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getPayment_idDirtyFlag())
            model.setPayment_id(domain.getPayment_id());
         if(domain.getCompany_currency_idDirtyFlag())
            model.setCompany_currency_id(domain.getCompany_currency_id());
         if(domain.getJournal_idDirtyFlag())
            model.setJournal_id(domain.getJournal_id());
         if(domain.getAnalytic_account_idDirtyFlag())
            model.setAnalytic_account_id(domain.getAnalytic_account_id());
         if(domain.getInvoice_idDirtyFlag())
            model.setInvoice_id(domain.getInvoice_id());
         if(domain.getTax_line_idDirtyFlag())
            model.setTax_line_id(domain.getTax_line_id());
         if(domain.getFull_reconcile_idDirtyFlag())
            model.setFull_reconcile_id(domain.getFull_reconcile_id());
         if(domain.getStatement_line_idDirtyFlag())
            model.setStatement_line_id(domain.getStatement_line_id());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getProduct_idDirtyFlag())
            model.setProduct_id(domain.getProduct_id());
         if(domain.getProduct_uom_idDirtyFlag())
            model.setProduct_uom_id(domain.getProduct_uom_id());
         if(domain.getPartner_idDirtyFlag())
            model.setPartner_id(domain.getPartner_id());
         if(domain.getAccount_idDirtyFlag())
            model.setAccount_id(domain.getAccount_id());
         if(domain.getStatement_idDirtyFlag())
            model.setStatement_id(domain.getStatement_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getUser_type_idDirtyFlag())
            model.setUser_type_id(domain.getUser_type_id());
         if(domain.getExpense_idDirtyFlag())
            model.setExpense_id(domain.getExpense_id());
        return model ;
    }

    public Account_move_line convert2Domain( Iaccount_move_line model ,Account_move_line domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Account_move_line();
        }

        if(model.getAnalytic_tag_idsDirtyFlag())
            domain.setAnalytic_tag_ids(model.getAnalytic_tag_ids());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getBalanceDirtyFlag())
            domain.setBalance(model.getBalance());
        if(model.getTax_idsDirtyFlag())
            domain.setTax_ids(model.getTax_ids());
        if(model.getAmount_currencyDirtyFlag())
            domain.setAmount_currency(model.getAmount_currency());
        if(model.getTax_line_grouping_keyDirtyFlag())
            domain.setTax_line_grouping_key(model.getTax_line_grouping_key());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getReconciledDirtyFlag())
            domain.setReconciled(model.getReconciled());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getBalance_cash_basisDirtyFlag())
            domain.setBalance_cash_basis(model.getBalance_cash_basis());
        if(model.getCredit_cash_basisDirtyFlag())
            domain.setCredit_cash_basis(model.getCredit_cash_basis());
        if(model.getQuantityDirtyFlag())
            domain.setQuantity(model.getQuantity());
        if(model.getAmount_residualDirtyFlag())
            domain.setAmount_residual(model.getAmount_residual());
        if(model.getRecompute_tax_lineDirtyFlag())
            domain.setRecompute_tax_line(model.getRecompute_tax_line());
        if(model.getTax_exigibleDirtyFlag())
            domain.setTax_exigible(model.getTax_exigible());
        if(model.getAmount_residual_currencyDirtyFlag())
            domain.setAmount_residual_currency(model.getAmount_residual_currency());
        if(model.getTax_base_amountDirtyFlag())
            domain.setTax_base_amount(model.getTax_base_amount());
        if(model.getParent_stateDirtyFlag())
            domain.setParent_state(model.getParent_state());
        if(model.getBlockedDirtyFlag())
            domain.setBlocked(model.getBlocked());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getMatched_credit_idsDirtyFlag())
            domain.setMatched_credit_ids(model.getMatched_credit_ids());
        if(model.getAnalytic_line_idsDirtyFlag())
            domain.setAnalytic_line_ids(model.getAnalytic_line_ids());
        if(model.getDate_maturityDirtyFlag())
            domain.setDate_maturity(model.getDate_maturity());
        if(model.getDebitDirtyFlag())
            domain.setDebit(model.getDebit());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getCounterpartDirtyFlag())
            domain.setCounterpart(model.getCounterpart());
        if(model.getMatched_debit_idsDirtyFlag())
            domain.setMatched_debit_ids(model.getMatched_debit_ids());
        if(model.getDebit_cash_basisDirtyFlag())
            domain.setDebit_cash_basis(model.getDebit_cash_basis());
        if(model.getCreditDirtyFlag())
            domain.setCredit(model.getCredit());
        if(model.getNarrationDirtyFlag())
            domain.setNarration(model.getNarration());
        if(model.getProduct_id_textDirtyFlag())
            domain.setProduct_id_text(model.getProduct_id_text());
        if(model.getUser_type_id_textDirtyFlag())
            domain.setUser_type_id_text(model.getUser_type_id_text());
        if(model.getPayment_id_textDirtyFlag())
            domain.setPayment_id_text(model.getPayment_id_text());
        if(model.getTax_line_id_textDirtyFlag())
            domain.setTax_line_id_text(model.getTax_line_id_text());
        if(model.getFull_reconcile_id_textDirtyFlag())
            domain.setFull_reconcile_id_text(model.getFull_reconcile_id_text());
        if(model.getExpense_id_textDirtyFlag())
            domain.setExpense_id_text(model.getExpense_id_text());
        if(model.getMove_id_textDirtyFlag())
            domain.setMove_id_text(model.getMove_id_text());
        if(model.getJournal_id_textDirtyFlag())
            domain.setJournal_id_text(model.getJournal_id_text());
        if(model.getCompany_currency_id_textDirtyFlag())
            domain.setCompany_currency_id_text(model.getCompany_currency_id_text());
        if(model.getInvoice_id_textDirtyFlag())
            domain.setInvoice_id_text(model.getInvoice_id_text());
        if(model.getAnalytic_account_id_textDirtyFlag())
            domain.setAnalytic_account_id_text(model.getAnalytic_account_id_text());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getCurrency_id_textDirtyFlag())
            domain.setCurrency_id_text(model.getCurrency_id_text());
        if(model.getRefDirtyFlag())
            domain.setRef(model.getRef());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getStatement_id_textDirtyFlag())
            domain.setStatement_id_text(model.getStatement_id_text());
        if(model.getStatement_line_id_textDirtyFlag())
            domain.setStatement_line_id_text(model.getStatement_line_id_text());
        if(model.getPartner_id_textDirtyFlag())
            domain.setPartner_id_text(model.getPartner_id_text());
        if(model.getAccount_id_textDirtyFlag())
            domain.setAccount_id_text(model.getAccount_id_text());
        if(model.getDateDirtyFlag())
            domain.setDate(model.getDate());
        if(model.getProduct_uom_id_textDirtyFlag())
            domain.setProduct_uom_id_text(model.getProduct_uom_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getMove_idDirtyFlag())
            domain.setMove_id(model.getMove_id());
        if(model.getCurrency_idDirtyFlag())
            domain.setCurrency_id(model.getCurrency_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getPayment_idDirtyFlag())
            domain.setPayment_id(model.getPayment_id());
        if(model.getCompany_currency_idDirtyFlag())
            domain.setCompany_currency_id(model.getCompany_currency_id());
        if(model.getJournal_idDirtyFlag())
            domain.setJournal_id(model.getJournal_id());
        if(model.getAnalytic_account_idDirtyFlag())
            domain.setAnalytic_account_id(model.getAnalytic_account_id());
        if(model.getInvoice_idDirtyFlag())
            domain.setInvoice_id(model.getInvoice_id());
        if(model.getTax_line_idDirtyFlag())
            domain.setTax_line_id(model.getTax_line_id());
        if(model.getFull_reconcile_idDirtyFlag())
            domain.setFull_reconcile_id(model.getFull_reconcile_id());
        if(model.getStatement_line_idDirtyFlag())
            domain.setStatement_line_id(model.getStatement_line_id());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getProduct_idDirtyFlag())
            domain.setProduct_id(model.getProduct_id());
        if(model.getProduct_uom_idDirtyFlag())
            domain.setProduct_uom_id(model.getProduct_uom_id());
        if(model.getPartner_idDirtyFlag())
            domain.setPartner_id(model.getPartner_id());
        if(model.getAccount_idDirtyFlag())
            domain.setAccount_id(model.getAccount_id());
        if(model.getStatement_idDirtyFlag())
            domain.setStatement_id(model.getStatement_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getUser_type_idDirtyFlag())
            domain.setUser_type_id(model.getUser_type_id());
        if(model.getExpense_idDirtyFlag())
            domain.setExpense_id(model.getExpense_id());
        return domain ;
    }


}
